*****************************
**MODELS OF WAR TERMINATION**
*****************************

***Concurrent Decapitation (No lag)***

**One-Year Break**
*All Conflicts 
stset duration, id(dyadep) failure(warends == 1)
stcox rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) texp(ln(_t)) tvc(rebelext secession lnpop)
estimates store m1

*Government Victory
stset duration, id(dyadep) failure(outcome_st == 1)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 2,3,4,5) texp(ln(_t)) tvc(activedyads)
estimates store m2

*Low Activity
stset duration, id(dyadep) failure(outcome_st == 2)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,3,4,5)
estimates store m3

*Settlement
stset duration, id(dyadep) failure(outcome_st == 3)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(rebstrength2)
estimates store m4

*Rebel Victory
stset duration, id(dyadep) failure(outcome_st == 4)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,3,5) texp(ln(_t)) tvc(activedyads)
estimates store m5

estout m1 m2 m3 m4 m5, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

**Three-Year Break**
*All Conflicts 
stset duration3, id(dyadep3) failure(warends3 == 1)
stcox rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) texp(ln(_t)) tvc(rebelext polity2 lnseverity)
estimates store m1

*Government Victory
stset duration3, id(dyadep3) failure(outcome_st3 == 1)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnseverity activedyads)
estimates store m2

*Low Activity
stset duration3, id(dyadep3) failure(outcome_st3 == 2)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(rebstrength2 polity2)
estimates store m3

*Settlement
stset duration3, id(dyadep3) failure(outcome_st3 == 3)
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,4,5)
estimates store m4

*Rebel Victory
stset duration3, id(dyadep3) failure(outcome_st3 == 4) 
stcrreg rebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,3,5)  texp(ln(_t)) tvc(activedyads)
estimates store m5

estout m1 m2 m3 m4 m5, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform


*****************************
**MODELS OF WAR TERMINATION**
*****************************

***Lagged Decapitation (t-1)***

**One-Year Break**
*All Conflicts 
stset duration, id(dyadep) failure(warends == 1)
stcox lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid)  
estimates store m1

*Government Victory
stset duration, id(dyadep) failure(outcome_st == 1)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 2,3,4,5) texp(ln(_t)) tvc(lnmilpers_ipop)
estimates store m2

*Low Activity
stset duration, id(dyadep) failure(outcome_st == 2)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,3,4,5)
estimates store m3

*Settlement
stset duration, id(dyadep) failure(outcome_st == 3)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,4,5) 
estimates store m4

*Rebel Victory
stset duration, id(dyadep) failure(outcome_st == 4)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,3,5) texp(ln(_t)) tvc(lnmilpers_ipop)
estimates store m5

estout m1 m2 m3 m4 m5, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

**Three-Year Break**
*All Conflicts 
stset duration3, id(dyadep3) failure(warends3 == 1)
stcox lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) 
estimates store m1

*Government Victory
stset duration3, id(dyadep3) failure(outcome_st3 == 1)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnseverity)
estimates store m2

*Low Activity
stset duration3, id(dyadep3) failure(outcome_st3 == 2)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(rebstrength2 secession)
estimates store m3

*Settlement
stset duration3, id(dyadep3) failure(outcome_st3 == 3)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,4,5)
estimates store m4

*Rebel Victory
stset duration3, id(dyadep3) failure(outcome_st3 == 4)
stcrreg lrebelext rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(lnmilpers_ipop)
estimates store m5

estout m1 m2 m3 m4 m5, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform


*************************
** KILLED OR CAPTURED? **
*************************

**MODELS OF WAR TERMINATION**

**One-Year Break**
*All Conflicts 
stset duration, id(dyadep) failure(warends == 1)
stcox killed_ts lnt_killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid)  texp(ln(_t)) tvc(secession lnpop)
estimates store m1

stcox captured_ts lnt_captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid)  texp(ln(_t)) tvc(secession lnpop)
estimates store m2

*Government Victory
stset duration, id(dyadep) failure(outcome_st == 1)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 2,3,4,5) texp(ln(_t)) tvc(activedyads)
estimates store m3

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 2,3,4,5) texp(ln(_t)) tvc(activedyads)
estimates store m4

*Low Activity
stset duration, id(dyadep) failure(outcome_st == 2)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,3,4,5)
estimates store m5

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,3,4,5)
estimates store m6

*Settlement
stset duration, id(dyadep) failure(outcome_st == 3)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(rebstrength2)
estimates store m7

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,4,5) texp(ln(_t)) tvc(rebstrength2)
estimates store m8

*Rebel Victory
stset duration, id(dyadep) failure(outcome_st == 4)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,3,5) texp(ln(_t)) tvc(activedyads)
estimates store m9

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st = 1,2,3,5) texp(ln(_t)) tvc(activedyads)
estimates store m10

estout m3 m4 m5 m6 m7 m8 m9 m10, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

**Three-Year Break**
*All Conflicts 
stset duration3, id(dyadep3) failure(warends3 == 1)
stcox killed_ts lnt3_killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) texp(ln(_t)) tvc( polity2 lnseverity)
estimates store m1

stcox captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) texp(ln(_t)) tvc( polity2 lnseverity)
estimates store m2

*Government Victory
stset duration3, id(dyadep3) failure(outcome_st3 == 1)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnseverity activedyads)
estimates store m3

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 2,3,4,5) texp(ln(_t)) tvc(lnseverity activedyads)
estimates store m4

*Low Activity
stset duration3, id(dyadep3) failure(outcome_st3 == 2)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(rebstrength2 polity2)
estimates store m5

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,3,4,5) texp(ln(_t)) tvc(rebstrength2 polity2)
estimates store m6

*Settlement
stset duration3, id(dyadep3) failure(outcome_st3 == 3)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,4,5)
estimates store m7

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,4,5)
estimates store m8

*Rebel Victory
stset duration3, id(dyadep3) failure(outcome_st3 == 4)
stcrreg killed_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(activedyads)
estimates store m9

stcrreg captured_ts rebstrength2 terrcont lnmilpers_ipop polity2 lnseverity secession activedyads lnpop if coup == 0 , r cluster(dyadid) compete(outcome_st3 = 1,2,3,5) texp(ln(_t)) tvc(activedyads)
estimates store m10

estout m1 m2, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform


**MODELS OF PEACE TERMINATION/WAR RECURRENCE**

*One-Year Break
stset peaceduration, id(peacedyad) failure(failure = 1)
stcox killed_peace secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m1
stcox killed_peace govvict lowactivity secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m2 
stcox govvict_kill govvict_nokill lowact_kill lowact_nokill secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m3

stcox captured_peace secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m4
stcox captured_peace govvict lowactivity secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m5 
stcox govvict_captured govvict_nocapture lowact_captured lowact_nocapture secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m6

estout m1 m2 m3, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform
estout m4 m5 m6, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform

*Three-year break
stset peaceduration3, id(peacedyad3) failure(failure3 = 1)
stcox killed_peace3 secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m1
stcox killed_peace3 lowactivity govvict secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m2
stcox govvict_kill govvict_nokill lowact_kill lowact_nokill secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m3

stcox captured_peace3 secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m4
stcox captured_peace3 lowactivity govvict secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m5
stcox govvict_captured govvict_nocapture lowact_captured lowact_nocapture secession lnsumseverity3 lnduration3 lnpop polity2 activedyads if outcome != 6, r cluster(dyadid)
estimates store m6

estout m1 m2 m3, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform
estout m4 m5 m6, cells(b (star fmt(%9.3f)) p(par)) stats(N N_sub N_fail chi2 ll , star fmt(%9.3f %9.0g)) eform


*****************************
** DETERMINANTS OF SUCCESS **
*****************************
*Leader
logit success founder lnpop lnseverity lnduration3, r cluster(dyadid)
estimates store m1
*Organizational Structure
logit success strengthcent2 lnpop lnseverity lnduration3, r cluster(dyadid) 
estimates store m2
logit success rebpolwing2 lnpop lnseverity lnduration3,  r cluster(dyadid) 
estimates store m3
logit success lnrebest lnpop lnseverity lnduration3, r cluster(dyadid)
estimates store m4
*Popular Support
logit success mobcap2 lnpop lnseverity lnduration3, r cluster(dyadid) 
estimates store m5
logit success islamist lnpop lnseverity lnduration3, r cluster(dyadid)
estimates store m6
*resources
logit success transconstsupp2 lnpop lnseverity lnduration3, r cluster(dyadid)
estimates store m7
logit success rebextpart2 lnpop lnseverity lnduration3, r cluster(dyadid)
estimates store m8
logit success rebelsupport2 lnpop lnseverity lnduration3, r cluster(dyadid)
estimates store m9

estout m1 m2 m3 m4 m5 m6 m7 m8 m9, cells(b (star fmt(%9.3f)) p(par)) stats(N chi2 ll , star fmt(%9.3f %9.0g)) eform
